export const getOption = (self) => {
  return {
    height: 'calc(100vh - 480px)',
    calcHeight: 30,
    selectionList: [],
    tip: false,
    searchShow: true,
    searchMenuSpan: 5,
    border: true,
    index: true,
    viewBtn: false,
    editBtn: false,
    delBtn: false,
    addBtn: false,
    indexLabel: '序号',
    columnBtn: false,
    selection: true,
    column: [
      {
        label: '检验单号',
        prop: 'documentNo',
        searchOrder: 7,
        type: 'search',
        search: true,
        appendClick: () => {
          self.openDocumentNoModel();
        }
      },
      {
        label: '巡检类型',
        prop: 'documentSubType',
        type: 'select',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        dicUrl: '/api/blade-system/dict/dictionary?code=ipqc_type'
      },
      {
        label: '车间',
        prop: 'workshopId',
        filterable: true,
        type: 'select',
        searchOrder: 5,
        search: true,
        hide: true,
        dicUrl: '/api/mes-admin/workshop/key-value',
        props: {
          label: 'workshopName',
          value: 'workshopId'
        }
      },
      {
        label: '车间',
        prop: 'workshopName'
      },
      {
        label: '产线',
        prop: 'lineName'
      },
      {
        label: '产线',
        prop: 'lineId',
        type: 'select',
        filterable: true,
        searchOrder: 2,
        search: true,
        hide: true,
        dicData: []
      },
      // {
      //   label: '巡检时段',
      //   prop: 'lineId21'
      // },
      {
        label: '巡检时段',
        prop: 'ipqcTimeframe'
        // type: 'select'
        // props: {
        //   label: 'dictValue',
        //   value: 'dictKey'
        // },
        // dicUrl: '/api/mes-product/qms-ipqc-timeframe/list'
      },
      {
        label: '生产工单',
        prop: 'sourceNo',
        type: 'search',
        searchOrder: 3,
        search: true,
        appendClick: () => {
          self.openWorkOrderCommonModal('pageWorkOrderModal');
        }
      },
      {
        label: '物料编码',
        prop: 'partNo',
        type: 'search',
        search: true,
        searchOrder: 1,
        appendClick: () => {
          self.openPartModal();
        }
      },
      {
        label: '物料名称',
        prop: 'partName'
      },
      {
        label: '产品型号',
        prop: 'partModel'
      },
      {
        label: '是否加急',
        prop: 'isUrgent',
        search: true,
        searchOrder: 4,
        type: 'select',
        dicData: [
          { label: '是', value: true },
          { label: '否', value: false }
        ]
      },
      {
        label: '检验状态',
        prop: 'status',
        type: 'select',
        dicData: [
          { label: '未检验', value: 1 },
          { label: '已检验', value: 2 },
          { label: '已撤销', value: 3 },
          { label: '草稿', value: 4 },
          { label: '超期关闭', value: 5 }
        ]
      },
      {
        label: '报检时间',
        prop: 'createTime'
      }
      // {
      //   label: '工段',
      //   prop: 'sectionNames',
      //   multiple: true,
      //   type: 'select',
      //   dicUrl: '/api/mes-product/qms-inspection-planconfig/get-section-vo-list-by-inspectType?inspectType=IQC&inspectSubType=SECTION',
      //   search: true,
      //   filterable: true,
      //   hide: true,
      //   searchOrder: 6,
      //   props: {
      //     label: 'name',
      //     value: 'id'
      //   }
      // }
    ]
  };
};
export const revokeOption = {
  submitBtn: false,
  emptyBtn: false,
  labelWidth: 150,
  group: [
    {
      label: '撤销原因',
      prop: 'revoke',
      arrow: false,
      icon: 'el-icon-vertical-bar',
      column: [
        {
          label: '撤销原因',
          prop: 'revocation',
          type: 'textarea',
          span: 24,
          maxRows: 3,
          minRows: 3,
          rules: [
            {
              required: true,
              message: '请输入撤销原因',
              trigger: 'blur'
            }
          ]
        }
      ]
    },
    {
      label: '基本信息',
      prop: 'basicInfo',
      arrow: false,
      icon: 'el-icon-vertical-bar',
      column: [
        // {
        //   label: '检验单号',
        //   prop: 'documentNo',
        //   disabled: true
        // },
        {
          label: '巡检类型',
          prop: 'documentSubType',
          type: 'select',
          props: {
            label: 'dictValue',
            value: 'dictKey'
          },
          disabled: true,
          dicUrl: '/api/blade-system/dict/dictionary?code=ipqc_type'
        },
        {
          label: '车间',
          prop: 'workshopName',
          disabled: true,
          // label: '车间',
          // prop: 'workshopId',
          type: 'select',
          dicUrl: '/api/mes-admin/workshop/key-value',
          props: {
            label: 'workshopName',
            value: 'workshopId'
          },
          rules: [
            {
              required: true,
              message: '请选择车间',
              trigger: 'blur'
            }
          ]
        },
        {
          label: '产线',
          prop: 'lineName',
          disabled: true
        },
        {
          label: '巡检时段',
          prop: 'ipqcTimeframe',
          type: 'select',
          props: {
            label: 'dictValue',
            value: 'id'
          },
          disabled: true,
          dicUrl: '/api/mes-product/qms-ipqc-timeframe/list',
          dicFormatter: (data) => {
            return data.data.data.map((item) => ({
              ...item,
              label: `${item.startTime}-${item.endTime}`
            }));
          }
        },
        {
          label: '生产工单',
          prop: 'sourceNo',
          disabled: true
        },
        {
          label: '工单数量',
          prop: 'workOrderQuantity',
          disabled: true
        },
        {
          label: '物料编码',
          prop: 'partNo',
          disabled: true
        },
        {
          label: '物料名称',
          prop: 'partName',
          disabled: true
        },
        {
          label: '产品型号',
          prop: 'partModel',
          disabled: true
        },
        {
          label: '是否加急',
          prop: 'isUrgent',
          type: 'switch',
          value: false,
          dicData: [
            {
              label: '否',
              value: false
            },
            {
              label: '是',
              value: true
            }
          ],
          disabled: true
        }
      ]
    }
  ]
};

export const getAddOption = (self) => {
  return {
    submitBtn: false,
    emptyBtn: false,
    labelWidth: 150,
    column: [
      {
        label: '巡检类型',
        prop: 'documentSubType',
        type: 'select',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        dicUrl: '/api/blade-system/dict/dictionary?code=ipqc_type',
        rules: [{ required: true, message: '请选择巡检类型' }]
      },
      // {
      //   label: '车间',
      //   prop: 'workshopId',
      //   filterable: true,
      //   type: 'select',
      //   searchOrder: 5,
      //   search: true,
      //   dicUrl: '/api/mes-admin/workshop/key-value',
      //   props: {
      //     label: 'workshopName',
      //     value: 'workshopId'
      //   }
      // },
      {
        label: '巡检时段',
        prop: 'ipqcTimeframe',
        type: 'select',
        dicData: [],
        rules: [{ required: true, message: '请选择巡检时段' }]
      },
      {
        label: '生产工单',
        prop: 'sourceNo',
        type: 'search',
        disabled: true,
        appendClick: () => {
          self.openWorkOrderCommonModal('addWorkOrderModal');
        }
      },
      {
        label: '产线',
        prop: 'lineId',
        type: 'select',
        filterable: true,
        dicData: [],
        change: ({ value, column }) => {
          const lineObj = self._find(column.dicData, { value: value });
          const { workshopId = '', workshopName = '' } = lineObj;
          self.addForm.workshopId = workshopId;
          self.addForm.workshopName = workshopName;
        }
      },
      {
        label: '车间',
        prop: 'workshopId',
        filterable: true,
        type: 'select',
        searchOrder: 5,
        search: true,
        dicUrl: '/api/mes-admin/workshop/key-value',
        props: {
          label: 'workshopName',
          value: 'workshopId'
        }
      },
      {
        label: '工单数量',
        prop: 'workOrderQuantity',
        disabled: true
      },
      {
        label: '物料编码',
        prop: 'partNo',
        disabled: true
      },
      {
        label: '物料名称',
        prop: 'partName',
        disabled: true
      },
      {
        label: '产品型号',
        prop: 'partModel',
        disabled: true
      },
      {
        label: '是否加急',
        prop: 'isUrgent',
        type: 'switch',
        value: false,
        dicData: [
          {
            label: '否',
            value: false
          },
          {
            label: '是',
            value: true
          }
        ]
      }
    ]
  };
};
